home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-02 | 2.3 KB | 74 lines | [TEXT/CGT1] |
- \ Circuit.ex2
-
- \ Example problem for use with LOGICA™.
- \ Copyright © 1992, LogicLab. All rights reserved.
-
- \ This example demonstrates Hyperresolution and demodulation.
- \ The goal is to find an electronic circuit, containing no more than
- \ three 2-input NAND gates, which computes the OR function.
-
- Logic: HyperRes;
- function: n, NAND, circuit, GateCount;
- predicate: output;
- constant: in1, in2;
-
- Demodulate:
- Rewrite(n(0,x),1); \ nand gate operation
- Rewrite(n(x,0),1); \ nand gate operation
- Rewrite(n(1,1),0); \ nand gate operation
-
- \ The format for the atoms of the following clauses
- \ is "output({x,x1,x2,x3},circuit(x4))",
- \ where the list {x, x1, x2, x3} is the 'truth table' for the circuit
- \ having binary inputs in1, in2 and circuit diagram x4.
- \
- \ in2 = 0 in2 = 1
- \ in1 = 0 x x1
- \ in1 = 1 x2 x3
- \
- \ The truth table is represented by the list of its entries, reading
- \ across the rows.
-
- Axiom:
- \ Represent the fact that if we can develop two circuits x4 and x9,
- \ then we can develop a circuit which computes the NAND X4 and x9:
-
- ~output({x,x1,x2,x3},circuit(x4),GateCount(x10)) |
- ~output({x5,x6,x7,x8},circuit(x9),GateCount(x11)) |
- output({n(x,x5),n(x1,x6),n(x2,x7),n(x3,x8)},
- circuit(NAND(x4,x9)),GateCount(x10 + x11 + 1)) |
- WHILE((x10 + x11 + 1) <= 3);
-
- Assert:
- \ Represent the truth tables for the two possible 'identity functions':
- \ the first outputs in1, the second outputs in2.
- \ The truth-table for the function "output = in1" is
- \
- \ [in1] in2 = 0 in2 = 1
- \ in1 = 0 0 0
- \ in1 = 1 1 1
- \
- \ Using the conventional ordering stated above (reading across the rows),
- \ this is represented as {0,0,1,1}:
-
- output({0,0,1,1},circuit(in1),GateCount(0)); \ output = in1
-
- \ The truth-table for the function "output = in2" is
- \
- \ [in2] in2 = 0 in2 = 1
- \ in1 = 0 0 1
- \ in1 = 1 0 1
- \
- \ Again, reading across the rows, this is represented as {0,1,0,1}:
-
- output({0,1,0,1},circuit(in2),GateCount(0)); \ output = in2
-
- \ Express the truth table for the desired result:
- \ the OR of two inputs, from any circuit diagram
- \ (here negated to assert the non-existence of a solution).
-
- ~output({0,1,1,1},circuit(x),GateCount(x1));
-
-
-
-